import '@css/insurePage.css'
import { insuranceListApi, searnameApi } from "@utils/api/productPage"
import { addordersApi } from "@utils/api/orderList"
window.addEventListener('DOMContentLoaded', async () => {
    var tt = decodeURI(window.location)
    let detailName = tt.split("=")[1]
    const { rows } = await searnameApi(detailName)
    console.log(rows[0].insurancesName)
    document.querySelector('.cancel').addEventListener('click', () => {
        document.querySelector('#payment').style.display = 'none'
    })
    document.querySelector('#immediate').addEventListener('click', () => {
        document.querySelector('#payment').style.display = 'none'
    })
    document.querySelector('.info').innerHTML = `${rows[0].insurancesName}(互联网版)`
    document.querySelector('.hand').innerHTML = `￥${rows[0].insurancesPrice}起`
    document.querySelector('.jine').innerHTML = `￥${rows[0].insurancesPrice}起`
    document.querySelector('.original').innerHTML = `原价：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;￥${rows[0].insurancesPrice}`
    document.querySelector('.deal').innerHTML = `应付金额：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;￥${rows[0].insurancesPrice}`
    document.querySelector('.addbtn').addEventListener('click', async () => {
        document.querySelector('#payment').style.display = 'block'
        let ordersName = document.querySelector('.ordersname').value
        let payPhone = document.querySelector('.ordersphone').value
        console.log(ordersName, payPhone)
        let warranty = { ordersName, payPhone }
        let ordrswarranty = JSON.stringify(warranty)
        const { code, message } = await addordersApi(ordrswarranty)
    })

})